home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Essential Home & Business Collection
/
The Essential Home & Business Collection.iso
/
27
/
3
/
5
/
HP22D5.ZIP
/
EXTERN
/
SETSCR.C
< prev
next >
Wrap
Text File
|
1991-04-16
|
2KB
|
95 lines
#include "extern.h" /* Extensions need these! */
#include "io.h"
/*
** This routine reads a .BSV file and replaces the page picture layer with
** it.
**
** To call this function from HyperPAD:
**
** put importBSV("pic1.bsv") into rc;
** if rc is "error" then
** answer "There was an error importing the picture." with "Ok";
*/
import(int NumArgs,HANDLE hFileName)
{
HANDLE hPic;
int handle = -1;
PTR rc;
if (NumArgs != 1) goto bad;
handle = open(deref(hFileName),READ);
if (handle == -1) goto bad;
hPic = NewHandle(4000);
if (!hPic) {
bad:
rc = "error";
ok:
if (handle != -1) close(handle);
ReturnValue(stoh(rc));
return(STOP);
}
read(handle,deref(hPic),7); /* read first 7 bytes */
read(handle,deref(hPic),4000); /* read the picture */
SetScreen( TRUE, /* set the page's picture */
1,1,80,25, /* rectangle to set */
deref(hPic)); /* picture data */
FreeHandle(hPic);
rc = "";
goto ok;
}
/*
** This routine clears the picture layer of the current page.
**
** To call fro HyperPAD:
**
** clearScreen;
*/
clear()
{
HANDLE hPic;
PTR p;
int i;
hPic = NewHandle(4000);
if (!hPic) return(STOP);
for (i=0,p=deref(hPic);i<2000;i++) {
*p++ = 0; /* character */
*p++ = 7; /* attribute */
}
SetScreen(TRUE,1,1,80,25,deref(hPic));
FreeHandle(hPic);
return(STOP);
}
POOL pascal Pool[] = {
{ "importBSV",
import,
0,
FUNCTION},
{ "clearScreen",
clear,
0,
HANDLER},
{ NULL,
NULL,
0,
0} };